//
//  ConstellationSingle.m
//  MINFOBBS
//
//  Created by juvid on 13-11-26.
//  Copyright (c) 2013年 minfo. All rights reserved.
//

#import "ConstellationSingle.h"
#import "UIColor+expanded.h"
#import "ConstellationController.h"
#import "MainSearchViewController.h"
@interface ConstellationSingle ()

@end

@implementation ConstellationSingle

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSString *str;
    NSString *tempConstel;
    if (self.isPair) {
        self.imgConstel.hidden=YES;
        NSArray *arr=[[[self.arrReturn objectAtIndex:0] objectForKey:@"Properties"] objectForKey:@"Property"];
        
        for (int i=0; i<arr.count; i++) {
            if ([[[arr objectAtIndex:i]objectForKey:@"name"]isEqual:@"详细"]) {
                str=[[arr objectAtIndex:i]objectForKey:@"text"];
            }
        }
        
        self.labCellContent.hidden=YES;
        self.btnYun.hidden=YES;
        self.imgLine.hidden=YES;
        [self.btnYun setTitle:@"点击查看配对详情" forState:UIControlStateNormal];
    }
    else{
         str=[[[[[self.arrReturn objectAtIndex:0] objectForKey:@"Properties"] objectForKey:@"Property"] objectAtIndex:0] objectForKey:@"text"];
        tempConstel=[[[[[self.arrReturn objectAtIndex:0] objectForKey:@"Properties"] objectForKey:@"Property"] objectAtIndex:0] objectForKey:@"name"];
        self.imgConstel.image=[UIImage imageNamed:tempConstel];
    }
    
//    self.imgConstel.hidden=NO;
    self.labCellContent.text=str;
    self.labCellContent.textColor=[UIColor colorWithHexString:@"0x4a4a4a"];
    [self.btnYun setTitleColor:[UIColor colorWithHexString:@"0xb7b7b7"] forState:UIControlStateNormal];
        str=nil;
    // Do any additional setup after loading the view from its nib.
}
-(void)viewDidAppear:(BOOL)animated{
     if (self.isPair) {
         self.labCellContent.hidden=NO;
         self.btnYun.hidden=NO;
         self.imgLine.hidden=NO;
    self.labCellContent.frame=CGRectMake(10, 10, self.view.frame.size.width-20, 90);
    self.imgLine.frame=CGRectMake(0, 104, self.view.frame.size.width, 3);
    self.btnYun.frame=CGRectMake(0, 107, self.view.frame.size.width, 35);
     }
     else{
          self.labCellContent.frame=CGRectMake(45, 5, self.view.frame.size.width-70, 34);
         self.imgConstel.frame=CGRectMake(15, 11, 20, 20);
     }
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (MainSearchViewController *)menuContainerViewController {
    return (MainSearchViewController *)self.parentViewController;
}
- (IBAction)PressNext:(id)sender {
    ConstellationController *constelCon=[[ConstellationController alloc]init];
//    NSLog(@"%@",[self.arrReturn objectAtIndex:0]);
    if (self.isPair) {
        constelCon.isPairing=YES;
        constelCon.arrReturn=self.arrReturn;
        
    }
    else{
    NSString *str=[[[[[self.arrReturn objectAtIndex:0]objectForKey:@"Links"] objectForKey:@"Link"]  objectAtIndex:0]objectForKey:@"href"];
    //        NSLog(@"%@",str);
    NSRange range = [str rangeOfString:@"query="];
    constelCon.strUrl=[str substringFromIndex:range.location +range.length];
    constelCon.isSingle=YES;
    str=nil;
    }
    [ [self menuContainerViewController].navigationController  pushViewController:constelCon animated:YES];
}
- (IBAction)next:(id)sender {
    NSLog(@"string");
}
@end
